package com.net.framework.help.utils;

import android.graphics.drawable.Drawable;
import android.widget.TextView;

/**
 * 设置图片
 */
public class TextViewCompoundDrawablesUtil {
    public static void setCompoundDrawables(TextView textView, int resDrawableId, TextGravity gravity) {
        Drawable drawable = UIUtils.getDrawable(resDrawableId);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        switch (gravity) {
            case LEFT:
                textView.setCompoundDrawables(drawable, null, null, null);
                break;
            case TOP:
                textView.setCompoundDrawables(null, drawable, null, null);
                break;
            case RIGHT:
                textView.setCompoundDrawables(null, null, drawable, null);
                break;
            case BOTTOM:
                textView.setCompoundDrawables(null, null, null, drawable);
                break;
        }
    }
}
